function getListInventory() {
    $("#pager").text("");
    $("#pageIndex").val("1");
    $('#searchInventoryForm').ajaxSubmit();
}

function getListInventoryCallBack(data) {
    $("#resultList").find("tr").remove();
    var resultList = data.inventoryList;
    if (resultList.length > 0) {
        $("#noInventoryList").hide();
        $("#inventoryList").show();
        $("#totalNumber").html(data.totalNumber);
        var resultReturnList = [];
        for (var i = 0; i < resultList.length; i++) {
            var result = [];
            result.push(resultList[i].sku);
            var product = resultList[i].product;
            if (product == null) {
                for (var j = 0; j < 3; j++) {
                    result.push("");
                }
            } else {
                //Product.upc =VendorProduct.externalProductId andProduct.productName=VendorProduct.itemName(Product Table had been instead of VendorProduct)
                result.push(resultList[i].product.externalProductId);
                result.push(resultList[i].product.itemName);
                result.push(resultList[i].product.productDescription);
            }
            result.push(resultList[i].warehouseCode);
            result.push(resultList[i].quantity);
            resultReturnList.push(result);
        }
        $("#resultList").find("tr").remove();
        pagination(resultReturnList, data.totalNumber, data.fetchSize);
    } else {
        $("#noInventoryList").show();
        $("#inventoryList").hide();
    }
}

function search() {
    var data = {};
    data.sKU = $("#sku").val();
    data.warehouseCode = $("#warehouseCode").val();
    data.pageIndex = $("#pageIndex").val();
    data.pageSize = $("#pageSize").val();
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: golbalRootUrl + "inventory/getListInventory",
        data: JSON.stringify(data),
        success: function (result) {
            getListInventoryCallBack(result);
        }
    });
}

function exportResult() {
    var param = "sKU=" + $("#sku").val() + "&warehouseCode=" + $("#warehouseCode").val();
    window.open(golbalRootUrl + "inventory/createExcelForInventory?" + param);
}